package com.jk.smartelderlycare.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author hhk
 * @version 1.0
 * @ClassName TborderRabbitConfig
 * @program: smart-elderly-care
 * @description: TODO
 * @date 2024/12/3 14:47
 */
@Configuration
public class TborderRabbitConfig {
    final static String message = "Tborder.message";

    //创建队列
    @Bean
    public Queue queueTborder(){
        return new Queue(TborderRabbitConfig.message);
    }

    //创建topic交换器(TopicExchange):topic 是RabbitMQ中最灵活的一种方式，可以根据routing_key自由的绑定不同的队列
    @Bean
    public TopicExchange exchangeA(){
        return new TopicExchange("exchangeA");
    }

    @Bean
    public Binding bindingExchange(Queue queueTborder , TopicExchange exchangeA){
        //          queueMessage队列    绑定到exchange     用topic.message 名字来绑定
        return BindingBuilder.bind(queueTborder).to(exchangeA).with("Tborder.message");
    }

}
